package Bridge.BagManage;

public class BagManage {
    public static void main(String[] args) {
        Color color;
        Bag bag;
        color = new Yellow();
        bag = new HandBag();
        bag.setColor(color);
        System.out.println(bag.getName());
        color = new Red();
        bag.setColor(color);
        System.out.println(bag.getName());
    }
}
//实现化角色：颜色
interface Color{
    String getColor();
}
//具体实现化角色：黄色
class Yellow implements Color{

    @Override
    public String getColor() {
        return "Yellow";
    }
}
//具体实现化角色：红色
class Red implements Color{

    @Override
    public String getColor() {
        return "Red";
    }
}
//抽象化角色：包
abstract class Bag{
    protected Color color;
    public void setColor(Color color){
        this.color = color;
    }
    public abstract String getName();
}
//拓展抽象化角色：挎包
class HandBag extends Bag{

    @Override
    public String getName() {
        return color.getColor()+"HandBag";
    }
}
//拓展抽象化角色：挎包
class Wallet extends Bag{

    @Override
    public String getName() {
        return color.getColor()+"Wallet";
    }
}